class LoadRes {
	private context: any;
	public constructor(context: any) {
		this.context = context;
	}
	private onConfigComplete(event: RES.ResourceEvent): void {
		RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this);
	}

	/**
	 * 加载配置文件
	 */
	public loadConfig() {
		var point = this;
		return new Promise(function (resolve, reject) {
			let assetAdapter = new AssetAdapter();
			egret.registerImplementation("eui.IAssetAdapter", assetAdapter);
			egret.registerImplementation("eui.IThemeAdapter", new ThemeAdapter());
			// initialize the Resource loading library
			//初始化Resource资源加载库
			RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE, function () {
				//this.onConfigComplete();
				resolve();
			}, point);
			RES.loadConfig(SystemManger.RESURL+"default.res.json", SystemManger.RESURL+"");
		});
	}
	/**
	 * 加载皮肤资源
	 */
	public loadTheme() {
		var point = this;
		return new Promise(function (resolve, reject) {
			let theme = new eui.Theme(SystemManger.RESURL+"default.thm.json", point.context.stage);
			theme.addEventListener(eui.UIEvent.COMPLETE, resolve, point);
		});

	}
}